<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html>
<html lang="zh-tw">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Proactive</title>
	<!-- favicon -->
	<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.ico">
	<link rel="Bookmark" href="images/favicon.ico" type="../image/x-icon"/>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- Add custom CSS here -->
    <link href="css/modern-business.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="css/egroupstyle.css" rel="stylesheet">
    <!-- bootstrap-datetimepicker css -->
    <link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">

</head>

<body>

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <!-- You'll want to use a responsive image option so this logo looks good on devices - I recommend using something like retina.js (do a quick Google search for it and you'll find it) -->
                <a class="navbar-brand" href="manageCardTemplate">Proactive</a>
            </div>
            <div>
                <ul class="nav navbar-nav">
                    <li class="dropdown"><a href="##"><i class="fa fa-user"></i>&nbsp;Hi,${loginManager.name} <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="logout">登出</a>
                            </li>
                        </ul>
                    </li>
                </ul>  
            </div>

            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="manageCardTemplate">活動管理</a>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>


    <div class="container tablestyle">
        <div class="row">
            <div class="col-lg-12">
                <br/>
                <ol class="breadcrumb">
                    <li><a href="manageCardTemplate">卡片樣式管理</a>
                    </li>
                    <li class="active">新增卡片樣式</li>
                </ol>
                 <a href="manageCardTemplate"><button type="button" class="btn btn-default btn-sm">
                  <span class="glyphicon glyphicon-chevron-left"></span> 回上頁
                </button></a>
                <br /><br />

        <div class="bs-docs-section">
        <div class="row">
          <div class="col-lg-12">
            <div class="well bs-component">
              <form class="form-horizontal" id="addForm" method="post" action="addCardTemplate" enctype="multipart/form-data">
                <fieldset>
                    <legend>新增卡片樣式</legend>
                    <div class="form-group">
                        <label for="title" class="col-lg-2 control-label">標題</label>
                        <div class="col-lg-8">
                          <input type="text" class="form-control" id="title" name="title" maxlength="30"><span id="msg1"></span>                    
                            <div class="checkbox">
                            <label>
                              <input type="checkbox" id="status" name="status" value="2"> 隱藏
                            </label>
                            </div>
                        </div>
                    </div>                  
                    <div class="form-group">
                        <label for="select" class="col-lg-2 control-label">活動</label>
                        <div class="col-lg-8">
                          <select class="form-control" id="aid" name="aid">
                          	<c:forEach items="${activityList}" var="activity">
	                            <option value="${activity.id}">${activity.title}</option>
                            </c:forEach>
                          </select>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label for="url" class="col-lg-2 control-label">課程連結</label>
                        <div class="col-lg-8">
                          <input type="text" class="form-control" id="url" name="url" maxlength="100">        
                        </div>
                    </div>      
                    <div class="form-group">
                        <label for="select" class="col-lg-2 control-label">範例呈現HTML</label>
                        <div class="col-lg-8">
                            <label class="input input-file state-error">       
                            <div class="button btn btn-success">
                                <input type="file" id="html1" name="html1" onchange="this.parentNode.nextSibling.value = this.value">瀏覽檔案上傳</div><input type="text" class="form-control"readonly=""><span id="msg2"></span>
                        </label>
                        </div>
                    </div>        
                    <div class="form-group">
                        <label for="select" class="col-lg-2 control-label">讀寫檔HTML</label>
                        <div class="col-lg-8">
                            <label class="input input-file state-error">       
                            <div class="button btn btn-success">
                                <input type="file" id="html2" name="html2" onchange="this.parentNode.nextSibling.value = this.value">瀏覽檔案上傳</div><input type="text" class="form-control"readonly=""><span id="msg3"></span> 
                        	
                        </label>
                        </div>
                    </div>        
                    <div class="form-group">
                        <label for="file" class="col-lg-2 control-label">封面圖片</label>
                        <div class="col-lg-8">    
                            <label class="input input-file state-error prevpiclabel">    
                                <div>
                                    <div class="previmg">
                                        <img src="images/previmgno.png" id="previewImage">
                                    </div>
                                    <div class="button btn btn-success picprevbtn"><input type="file" id="image" name="image" onchange="this.parentNode.nextSibling.value = this.value">瀏覽檔案上傳</div><input type="text" class="form-control picprevform"readonly=""><span id="msg4"></span>
                                </div>
                            </label>
                        </div>
                    </div>        

                 
                       
                    <div class="form-group">
                        <div class="col-lg-10 col-lg-offset-2">
                        <hr>
                          <button type="submit" class="btn btn-warning">送出</button>
                        </div>
                    </div>

                </fieldset>
              </form>


            </div>
          </div>
        </div>
        </div><!-- bs-docs-section-->


        </div><!-- col-lg-12-->
        </div><!--row -->      
    </div><!--container -->   


    <div class="container">

        <hr>

        <footer>
            <div class="row">
                <div class="col-lg-12">
                    <p>Copyright &copy; Company 2013</p>
                </div>
            </div>
        </footer>

    </div>
    <!-- /.container -->

    <!-- JavaScript -->
    <script src="js/jquery-1.10.2.js"></script>
    <script src="js/bootstrap.js"></script>
    <script src="js/modern-business.js"></script>
    <script type="text/javascript" src="js/jquery.validate.js"></script>
	<script type="text/javascript" src="js/additional-methods.js"></script>
	<script type="text/javascript" src="js/messages_zh_TW.js"></script>
    <!-- preview image -->
    <script src="js/previewimg.js"></script>

    <script type="text/javascript">
    $(function(){
		$("#addForm").validate({
			rules:{
				title:"required",
				html1:{
					required: true,
					extension:"html",
					filesize: 1048576 
				},
				html2:{
					required: true,
					extension:"html",
					filesize: 1048576
				},
				image:{
					required: true,
					extension:"jpg|png|jpeg|gif",
					filesize: 1048576
				}
			},
			messages:{
				title:"請填寫標題",
				html1:{
					required:"請選擇範例呈現HTML",
					extension:"檔案格式錯誤，請選擇HTML格式",
					filesize:"檔案大小上限為1MB"
				},
				html2:{
					required:"請選擇讀寫檔HTML",
					extension:"檔案格式錯誤，請選擇HTML格式",
					filesize:"檔案大小上限為1MB"
				},
				image:{
					required:"請選擇圖片",
					extension:"檔案格式錯誤，請選擇圖片格式",
    				filesize:"圖片大小上限為1MB"
				}
			},
			errorPlacement: function (error, element) {
    	    	if(element.attr('name') == "title"){
    	            $("#msg1").append(error);
    	    	}
    	    	else if(element.attr('name') == "html1"){
    	            $("#msg2").append(error);
    	    	}
    	    	else if(element.attr('name') == "html2"){
    	            $("#msg3").append(error);
    	    	}
    	    	else if(element.attr('name') == "image"){
    	            $("#msg4").append(error);
    	    	}
    	    	else
    	    		error.insertBefore(element);
    	    }
		});
		
 		$("#image").change(function(){
 			previewImage(this,$("#previewImage"),"images/previmgno.png");
     	});
	});     

    </script>
</body>

</html>
